From: Carlos Garnacho Date: Sun, 27 Nov 2022 12:10:53 +0000 (+0100) Subject: gtktext: Invoke OSK on button/touch taps that move/undo selection X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~65^2~3 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=ee6d9478c80d2d913c98dcf9e7db5c7d31e28fbd;p=gtk4.git gtktext: Invoke OSK on button/touch taps that move/undo selection If the ::release handler is invoked, the press/release happened without drags in between. Additionally check that the press did not happen within the selection, and that there is no selection at all. This makes OSK invoked on taps that move the caret around, while tapping in the selection invokes edition popup and text handles without bringing in the OSK. --- diff --git a/gtk/gtktext.c b/gtk/gtktext.c index e58355e403..0cc3a6c4f1 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -42,6 +42,7 @@ #include "gtkgestureclick.h" #include "gtkgesturesingle.h" #include "gtkimageprivate.h" +#include "gtkimcontextprivate.h" #include "gtkimcontextsimple.h" #include "gtkimmulticontext.h" #include @@ -465,10 +466,15 @@ static void gtk_text_motion_controller_motion (GtkEventControllerMotion *c double y, GtkText *self); static void gtk_text_click_gesture_pressed (GtkGestureClick *gesture, - int n_press, - double x, - double y, - GtkText *self); + int n_press, + double x, + double y, + GtkText *self); +static void gtk_text_click_gesture_released (GtkGestureClick *gesture, + int n_press, + double x, + double y, + GtkText *self); static void gtk_text_drag_gesture_update (GtkGestureDrag *gesture, double offset_x, double offset_y, @@ -1897,6 +1903,8 @@ gtk_text_init (GtkText *self) gtk_event_controller_set_static_name (GTK_EVENT_CONTROLLER (gesture), "gtk-text-click-gesture"); g_signal_connect (gesture, "pressed", G_CALLBACK (gtk_text_click_gesture_pressed), self); + g_signal_connect (gesture, "released", + G_CALLBACK (gtk_text_click_gesture_released), self); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0); gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE); gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture)); @@ -2876,6 +2884,21 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture, gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture)); } +static void +gtk_text_click_gesture_released (GtkGestureClick *gesture, + int n_press, + double widget_x, + double widget_y, + GtkText *self) +{ + GtkTextPrivate *priv = gtk_text_get_instance_private (self); + + if (n_press == 1 && + !priv->in_drag && + priv->current_pos == priv->selection_bound) + gtk_im_context_activate_osk (priv->im_context); +} + static char * _gtk_text_get_selected_text (GtkText *self) {